package com.tuanzi.loan.business.service.family.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tuanzi.loan.business.repository.family.LoanApiRecordRepository;
import com.tuanzi.loan.business.service.family.LoanApiRecordService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.jiafang.NuanXinDaiUnionSearchRequest;
import com.tuanzi.loan.vo.response.jiafang.NuanXinDaiUnionSearchResponse;

@Debug
@Service
@Transactional
@Retryable(value = { RetryException.class })
public class LoanApiRecordServiceImpl implements LoanApiRecordService {

	@Autowired
	private LoanApiRecordRepository loanApiRecordRepository;

	@Override
	public Page<NuanXinDaiUnionSearchResponse> statNuanXinDaiUnion(PageSearcher<NuanXinDaiUnionSearchRequest> pageSearcher) {
		return loanApiRecordRepository.statNuanXinDaiUnion(pageSearcher.getSearchCondition(), pageSearcher.getPageable());
	}

	@Override
	public Long countByUserIdAndSourceId(Long userId, Long sourceId) {
		return loanApiRecordRepository.countByUserIdAndSourceId(userId, sourceId);
	}
}
